Skip to main content

Chip

Import

To add the Chip component to your project you can import it as follows:

import { Chip } from '@amalgamaco/embassy-ui';

Example

Chip
const [ isSelected, setSelected ] = useState( false );

return (
<Chip
label="Chip"
selected={isSelected}
icon={<Icon name="earth-outline" as={Ionicons} />}
onPress={() => setSelected( !isSelected )}
onDeletePress={() => { window?.alert( 'Delete pressed!' ); }}
/>
);

Props

label

The label text to show above the chip component.

TYPEREQUIRED
stringNo
Label text
<Chip label="Label text" />

icon

An icon to show at left side of the chip.

TYPEREQUIRED
ReactElement<IIconProps>No
Chip
<Chip
label="Chip"
icon={<Icon name="earth-outline" as={Ionicons} />}
/>

selected

If the chip is selected or not.

TYPEREQUIREDDEFAULT
booleanNofalse
Chip
Chip
<Chip label="Chip" />
<Chip label="Chip" selected />

onPress

A callback that is called when the chip is pressed.

TYPEREQUIRED
(): voidNo
Chip
<Chip
label="Chip"
onPress={() => { window.alert( 'Chip pressed!' );}}
/>

onDeletePress

A callback that is called when the chip's delete icon is pressed.

TYPEREQUIRED
(): voidNo
info

The delete icon is only shown when this prop is not undefined nor null.

Chip
<Chip
label="Chip"
onDeletePress={() => { window.alert( 'Delete pressed!' );}}
/>

deleteIcon

The icon used as the delete icon.

TYPEREQUIRED
ReactElement<IIconProps>No
info

Remember that the delete icon is only shown when the onDeletePress prop is not undefined nor null.

Chip
<Chip
label="Chip"
onDeletePress={() => { window.alert( 'Delete pressed!' );}}
deleteIcon={<Icon name="trash-outline" as={Ionicons} />}
/>

disabled

If the chip is disabled or not. Boolean.

Chip
<IconButton size="md" name="plus" disabled />

Pseudo Props

__label

Props to be applied to the internal text component showing the label text.

TYPEREQUIRED
ITextPropsNo

__icon

Props to be applied to the internal icon component.

TYPEREQUIRED
IIconPropsNo

__deleteIcon

Props to be applied to the internal delete icon component.

TYPEREQUIRED
IIconPropsNo

__stack

Props to be applied to the internal delete stack component holding the left icon, the label and the delete icon.

TYPEREQUIRED
IBoxPropsNo